<%@page import="com.mongodb.DBObject"%>
<%@page import="com.mongodb.DBCursor"%>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<%@ page import="com.jiangjun.fetch.mongo.MongoDBSupport"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>管理</title>
<script type="text/javascript" src="js/jquery.js"></script>
<link type="text/css" rel="stylesheet" href="css/common.css"/>
<script>
$(document).ready(function(){
	
	$.ajax({
		type : "get",
		dataType : "json",
		url : "showWeiboAction.do?type=0",
		data : "cpage=" + 1,
		success : function(msg){
			$(msg).each(function(){
				var json = eval(this);
				var vhtml = "<tr><td>" + json.id + "</td><td>" + json.parent_name + "</td><td>" + json.title + "</td><td>" +json.txt + "</td><td><img src=" + json.img_path + " /></td><td>" +json.date + "</td><td><select id="+json.id+" onchange='change(" +json.id+ ")';><option value='0'>未审核</option><option value='1'>文本</option><option value='2'>图片</option><option value='3'>删除</option></select></td></tr>";
				$('#mytable').append(vhtml);
				});
			var pi = parseInt($('#pageIndex').val());
			$('#pageIndex').val(pi + 1);
			}
		});
	$('#loadMore').click(function(){
		var pageIndex = $('#pageIndex').val();
		$.ajax({
			type : "get",
			dataType : "json",
			url : "showWeiboAction.do?type=0",
			data : "cpage=" + pageIndex,
			success : function(msg){
				$(msg).each(function(){
					var json = eval(this);
					var vhtml = "<tr><td>" + json.id + "</td><td>" + json.parent_name + "</td><td>" + json.title + "</td><td>" +json.txt + "</td><td><img src=" + json.img_path + " /></td><td>" +json.date + "</td><td><select id="+json.id+" onchange='change(" +json.id+ ")';><option value='0'>未审核</option><option value='1'>文本</option><option value='2'>图片</option><option value='3'>删除</option></select></td></tr>";
					$('#mytable').append(vhtml);
					});
				var pi = parseInt($('#pageIndex').val());
				$('#pageIndex').val(pi + 1);
				}
			});
	});
})
function change(id)
{
	var v = $('#'+id).val();
	window.location.href="updateWeiboAction.do?id=" + id + "&type=" + v;
}
</script>
</head>
<body>
	<div>
		<input type="hidden" id="pageIndex" name="pageIndex" value="1"/>
		<table id="mytable">
			<tr>
				<th>ID</th>
				<th>分类</th>
				<th>标题</th>
				<th>内容</th>
				<th>图片</th>
				<th>时间</th>
				<th>审核</th>
			</tr>
		</table>
	</div>
	<div>
		<button id="loadMore" name="loadMore" value="加载更多">加载更多</button>
	</div>
</body>
</html>
